package apiday05.exception;

public class TryCatchDemo {
    public static void main(String[] args) {
        System.out.println("程序开始了");
        try {
//            String line = null;
//            String line = "abc按不出";
            String line = "tryCatch";
            System.out.println(line.length());
            System.out.println(line.charAt(6));
            System.out.println(Integer.parseInt(line));
//        } catch (NullPointerException e) {
//            System.out.println("出现了空指针异常，但是解决啦！");
//        }catch (IndexOutOfBoundsException e){
//            System.out.println("出现了数组越界异常，但是解决啦！");
//        }
        }catch (NullPointerException|IndexOutOfBoundsException e){
            System.out.println("出现了数组越界异常或出现了空指针异常，但是解决啦！");
        }catch (Exception e){
            System.out.println("出现了异常，但是解决了！");
        }
        System.out.println("程序结束了");

    }
}
